class Solution:
    def myPow(self, x: float, n: int) -> float:
        if n == 0:
            return 1.0
        elif n == 1:
            return x
        elif n > 0:
            if n & 1 == 0:
                temp = self.myPow(x, n >> 1)
                return temp * temp
            else:
                return self.myPow(x, n - 1) * x
        else:
            return 1 / self.myPow(x, -n)